#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QProcess>
#include "ui_mainwindow.h"
#include <iostream>
#include <string>
class QPushButton;
class QString;

#include <queue>
#include <string>

#include <boost/array.hpp>
#include <boost/bind.hpp>
#include <boost/smart_ptr.hpp>
#include <boost/random.hpp>
#include <boost/asio.hpp>

#include "TcpTunnelBuilder.h"
#include "XORCryptoFactory.h"
#include "BandwithLimitSendProxy.h"

using namespace std;
using namespace boost::asio;
using namespace encrypted::tunnel;

class MainWindow : public QMainWindow,public Ui::MainWindow
{
    Q_OBJECT
    public:

    typedef XORCryptoFactory<boost::shared_array<unsigned char> > CryptoFactory;
    typedef boost::shared_ptr<CryptoFactory> CryptoFactoryPtr;
    typedef CryptoFactory::DecryptorPtr CryptoPtr;
    typedef BandwithLimitSendProxy<CryptoPtr> SendProxy;
    typedef boost::shared_ptr<SendProxy> SendProxyPtr;
    enum Status{
        Client,
        Server,
    };

    MainWindow(QWidget *parent = 0);
    ~MainWindow();
private slots:

    void launch();
protected:
    void tohex(unsigned char& hi, unsigned char& lo, unsigned char from);
    unsigned char  fromhex(unsigned char hi, unsigned char lo);
    void secretKeyProcess(std::string secretKey);
private:
    int start(std::string listenPort,
              std::string connectPort,
              std::string connectIP,
              int mode,
              unsigned int bandWidth ,
              unsigned int randSeed ,
              std::string secretKey ,
              std::string bindHost);
    QPushButton *button;
    Status status;
    int bandWidth;
    std::string listenPort, connectPort, connectIP, secrectKey, bindHost;
};
#endif // MAINWINDOW_H
